package cn.com.joycode.nimble.core.message;

import cn.com.joycode.nimble.core.utils.ObjectMapperUtil;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.map.MapUtil;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;

public class NbMsgHashMap extends HashMap<String, Object> {

    public <T> T get(String key) {
        return (T) super.get(key);
    }

    public <T> T get(String key, Class<T> clazz) {
        return MapUtil.get(this, key, clazz);
    }

    public <T> T get(String key, TypeReference<T> reference) {
        return MapUtil.get(this, key, reference);
    }

    public String getStr(String key) {
        return MapUtil.getStr(this, key);
    }

    public Integer getInt(String key) {
        return MapUtil.getInt(this, key);
    }

    public Long getLong(String key) {
        return MapUtil.getLong(this, key);
    }

    public Float getFloat(String key) {
        return MapUtil.getFloat(this, key);
    }

    public Double getDouble(String key) {
        return MapUtil.getDouble(this, key);
    }

    public Boolean getBool(String key) {
        return MapUtil.getBool(this, key);
    }

    public BigDecimal getBigDeciaml(String key) {
        return MapUtil.get(this, key, BigDecimal.class);
    }

    public Date getDate(String key) {
        return MapUtil.getDate(this, key);
    }

    @Override
    public String toString() {
        return ObjectMapperUtil.toJsonString(this);
    }
}
